import http from './http'

/**
 * resquest_user user接口根路径
 * request_admin admin接口根路径
 * request_file file接口根路径
 */
let resquest_user = "/user",
  request_admin = "/admin",
  request_file = "/file",
  request_share = "/share";

//导出接口
const common = {//公用接口
  refreshToken(params) {//token过期 刷新token
    //"token": "string"
    return http.post(`${resquest_user}/refreshToken`, params)
  },
},
  /** */
  user = {//用户接口
    common: {//公用 注册和登录
      getMessageToken(params) {//获取消息验证码 短信/邮件
        /*
          "captchaType": "LOGIN",//注册传REGISTER
          "token": "string"
        */
        return http.post(`${resquest_user}/getMessageToken`, params)
      },
      info(params) {//用于刷新之后 重新获取userinfo
        /*
          在header中携带token
        */
        return http.post(`${resquest_user}/info`, params)
      },
      getContainerSize(params) {//上传和删除后重新获取容量
        /*
          在header中携带token
        */
        return http.post(`${resquest_user}/getContainerSize`, params)
      },
    },
    login: {//登录
      getImgToken(params) {//登录获取图片验证码
        /* 
         "randomKey":"string"
        */
        return http.get(`${resquest_user}/getImgToken`, params)
      },
      login(params) {//登录提交表单
        /*
          "captcha": "string",
          "password": "string",
          "token": "string",
          "username": "string"
        */
        return http.post(`${resquest_user}/login`, params)
      },
    },
    register: {//注册
      nameCheck(params) {//检查name唯一性
        /*
          "name": "string"
        */
        return http.post(`${resquest_user}/nameCheck`, params)
      },
      phoneCheck(params) {//检查phone唯一性
        /*
          "name": "string"
        */
        return http.post(`${resquest_user}/phoneCheck`, params)
      },
      register(params) {//注册提交表单
        /*
          "captcha": "string",
          "password": "string",
          "phone": "string",
          "username": "string"
        */
        return http.post(`${resquest_user}/register`, params)
      }
    },
    forget: {//找回密码密码
      verifyAccount(params) {//校验name存在
        /*
          "name": "string"
        */
        return http.post(`${resquest_user}/verifyAccount`, params)
      },
      changeForgetPassword(params) {//重置密码
        /*
          "captcha": "string",
          "newPassword": "string",
          "username": "string"
        */
        return http.post(`${resquest_user}/changeForgetPassword`, params)
      }
    },
    personal: {//个人中心
      changePassword(params) {//修改密码
        return http.post(`${resquest_user}/changePassword`, params)
      },
      getUserInfo(params) {//获取用户信息
        return http.post(`${resquest_user}/info`, params)
      },
      emailCheck(params) {//检查email唯一性
        /*
          "name": "string"
        */
        return http.post(`${resquest_user}/emailCheck`, params)
      }
    }
  },
  admin = {//管理员接口
  },
  file = {//文件接口
    common: {//公共接口  上传成功后添加文件 和 新增文件夹
      add(params) {
        /* 
         "fileType": "ROOT",
        "md5": "string",
        "name": "string",
        "pathId": 0,
        "size": 0,
        "tag": "string"
        */
        return http.post(`${request_file}/add`, params)
      }
    },
    upload: {//上传接口
      getUUID(params) {
        return http.post(`${request_file}/getUUID`, params)
      },
      combine(params) {
        /* "uuid":string */
        return http.post(`${request_file}/combine`, params)
      }
    },
    operate: {//操作接口
      get(params) {
        /*  id:0 */
        return http.post(`${request_file}/get`, params)
      },
      home(params) {
        return http.post(`${request_file}/home`, params)
        //return request(`${request_file}/home`, {data})
      },
      searchFile(params) {
        /* (type: 分类名)//搜索不需要
        name:string */
        return http.post(`${request_file}/searchFile`, params)
      },
      delete(params) {
        /*"idList": [] */
        return http.post(`${request_file}/delete`, params)
      },
      rename(params) {
        /*"id": number
           'name':string  */
        return http.post(`${request_file}/rename`, params)
      },
      move(params) {
        /*"moveFileIds": [],
             "toFileId": number */
        return http.post(`${request_file}/move`, params)
      },
      copy(params) {
        /*"moveFileIds": [],
             "toFileId": number */
        return http.post(`${request_file}/copy`, params)
      }
    },
    share: {//分享接口
      add(params) {
        /*"moveFileIds": [],
             "toFileId": number */
        return http.post(`${request_share}/copy`, params)
      },
      getShareFile(params) {
        /*"code": "string",
          "image": "string" */
        return http.post(`${request_share}/getShareFile`, params)
      },
      makeShareImage(params) {
        /*"fileIdList": [],
         "shareType": ['ONE_DAY', 'SEVEN_DAY', 'FOREVER'] */
        return http.post(`${request_share}/makeShareImage`, params)
      }
    }
  }

export {
  common as commonAPI,
  user as userAPI,
  admin as adminAPI,
  file as fileAPI
}
